package com.zero.service;

import com.zero.service.impl.BasicVerify;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Component
@org.aspectj.lang.annotation.Aspect
public class Aspect {

    /*@Pointcut(value = "execution(* com.zero.service.impl.UserService.*(..))")
    public void pointcut(){

    }*/

    @Pointcut(value = "@annotation(com.zero.service.AopAnnotation)")
    public void pointcut(){

    }

    @Before("pointcut()")
    public void before(JoinPoint joinPoint){
        System.out.println("方法执行前." + joinPoint.getArgs());
    }

    /*@Around("pointcut()")
    public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        proceedingJoinPoint.proceed();
    }*/

    @After("pointcut()")
    public void after(JoinPoint joinPoint){
        System.out.println("方法执行后");

    }

    @Around("pointcut()")
    public void around(ProceedingJoinPoint proceedingJoinPoint){

    }

    @AfterReturning("pointcut()")
    public void afterReturning(JoinPoint joinPoint){
        System.out.println("方法执行后返回");
    }

    @DeclareParents(value = "com.zero.service.impl.UserService", defaultImpl = BasicVerify.class)
    private Verify verify;
}
